from listnode import ListNode, ln_to_list, list_to_ln


def merge_klists(lists):
    if len(lists) == 0:
        return
    tmp = []
    for i in lists:
        tmp.extend(ln_to_list(i))
    tmp.sort()
    return list_to_ln(tmp)


if __name__ == '__main__':
    print(ln_to_list(merge_klists([list_to_ln([1, 4, 5]), list_to_ln([1, 3, 4]), list_to_ln([2, 6])])))
